Atmospheric Temperature#
import warnings
warnings.filterwarnings("ignore")
import os
import sys
import folium
import numpy as np
sys.path.append("../../../../indicators_setup")
from ind_setup.plotting_int import plot_timeseries_interactive
from ind_setup.colors import get_default_line_colors
sys.path.append("../../../functions")
from data_downloaders import GHCN
Define location and variables of interest#
country = 'Palau'
vars_interest = ['TMIN', 'TMAX']
Get Data#
df_country = GHCN.get_country_code(country)
print(f'The GHCN code for {country} is {df_country["Code"].values[0]}')
The GHCN code for Palau is PS
df_stations = GHCN.download_stations_info()
df_country_stations = df_stations[df_stations['ID'].str.startswith(df_country.Code.values[0])]
print(f'There are {df_country_stations.shape[0]} stations in {country}')
There are 13 stations in Palau
GHCND_dir = 'https://www.ncei.noaa.gov/data/global-historical-climatology-network-daily/access/'
for var in vars_interest:
globals()[f"dict_{var}"], IDS = GHCN.extract_dict_data_var(GHCND_dir, var, df_country_stations)
Plot Data#
map = folium.Map(location=[df_country_stations.iloc[0].Latitude-.25, df_country_stations.iloc[0].Longitude], zoom_start=10)
# Color list
colors = get_default_line_colors()
# Add markers
ids_with_data = df_country_stations[df_country_stations['ID'].isin(np.unique(IDS))]
for i in range(len(ids_with_data)):
folium.Marker(
location=[ids_with_data.iloc[i].Latitude, ids_with_data.iloc[i].Longitude],
popup=ids_with_data.iloc[i]['ID'] + ids_with_data.iloc[i]['Name'],
icon=folium.DivIcon(
html=f'<div style="font-size: 25px; color: white; background-color: {colors[i]}; line-height: 1; width: 24px; padding: 0px;">☉</div>'
)
).add_to(map)
map
Make this Notebook Trusted to load map: File -> Trust Notebook
for var in vars_interest:
dict_plot = globals()[f'dict_{var}']
fig = plot_timeseries_interactive(dict_plot, trendline=False, ylims = [5, 40])